#include<stdio.h>
#include<sys/types.h>
#include<string.h>
#include<stdlib.h>
#include<fcntl.h>
#include<unistd.h>
#define  LT  "log.txt" 
int main()
{
  int fp;
  char buffer[128];
  memset(buffer,0,sizeof(buffer));
  fp=open(LT,O_CREAT|O_RDWR);//读写权限
  char str[20]="linux so easy!";
  if(fp<0)
  {
    printf("open failed\n");
    return -1;
  }
  write(fp,str,strlen(str));
  

  lseek(fp,0,SEEK_SET);
  
  read(fp,buffer,sizeof(buffer));


  
  
  printf("%s\n",buffer);





  close(fp);



  return 0;
}
